import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '设备分类',
    align:"center",
    dataIndex: 'category_dictText'
   },
   {
    title: '设备名称',
    align:"center",
    dataIndex: 'name'
   },
   {
     title: '设备编码',
     align:"center",
     dataIndex: 'code'
    },
   {
    title: '设备IP',
    align:"center",
    dataIndex: 'ip'
   },
   {
    title: '设备端口号',
    align:"center",
    dataIndex: 'port'
   },
//    {
//     title: '设备登录用户名',
//     align:"center",
//     dataIndex: 'username'
//    },
//    {
//     title: '设备登录密码',
//     align:"center",
//     dataIndex: 'password'
//    },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '设备分类',
    field: 'category',
    component: 'JDictSelectTag',
    componentProps: () => {
      return {
        dictCode: 'equipment_category',
      }
    },
  },
  {
      label: '设备名称',
      field: 'name',
      component: 'JInput',
   },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '设备分类',
    field: 'category',
    component: 'JDictSelectTag',
    componentProps: () => {
      return {
        dictCode: 'equipment_category',
        type: 'radio'
      }
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择设备分类!'},
          ];
     },
  },
  {
    label: '设备名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备名称!'},
          ];
     },
  },
  {
      label: '设备编码',
      field: 'code',
      component: 'Input',
      dynamicRules: ({model,schema}) => {
            return [
                   { required: true, message: '请输入设备编码!'},
            ];
       },
    },
  {
    label: '设备IP',
    field: 'ip',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备ip!'},
          ];
     },
  },
  {
    label: '设备端口号',
    field: 'port',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入设备端口号!'},
          ];
     },
  },
  {
    label: '设备登录用户名',
    field: 'username',
    component: 'Input',
  },
  {
    label: '设备登录密码',
    field: 'password',
    component: 'Input',
  },

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  tenantId: {title: '租户号',order: 0,view: 'text', type: 'string',},
  name: {title: '设备名称',order: 2,view: 'text', type: 'string',},
  ip: {title: '设备ip',order: 3,view: 'text', type: 'string',},
  port: {title: '设备端口号',order: 4,view: 'text', type: 'string',},
  username: {title: '设备登录用户名',order: 5,view: 'text', type: 'string',},
  password: {title: '设备登录密码',order: 6,view: 'text', type: 'string',},
  category: {title: '设备分类;monitor/监控设备；dvr/硬盘录像机；palm_vein/掌静脉打卡设备；',order: 7,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
